<!DOCTYPE html>
<html>
  <head>
    <title>realtimeDB</title>
	<link rel="shortcut icon" href="#" />
  </head>
  <body>
      <div>loaded</div>
    <script src="/socket.io/socket.io.js"></script>
	
    <script>
      
	var socket;

	function setWebViewString(d){
		console.log(JSON.stringify(d));
		if(window.AppInventor){
			window.AppInventor.setWebViewString(JSON.stringify(d));
		}
	}
	
	function connect(nsp){
		socket= io("/" + nsp);
		
		socket.on('connect', function () {
			var data ={};
			data.eventname="Connected";
			setWebViewString(data);
		});
		
		socket.on('DataChanged', function (data) {
			setWebViewString(data);
		});
		
		socket.on("goterror", function(data){
			data.eventname="goterror";
			setWebViewString(data);
		});
	}
	var nsp = window.location.pathname.substring(1);
	connect(nsp);

	
    </script>
  </body>
</html>